package com.jdaoyun.execute;


import cn.hutool.core.util.ObjectUtil;
import com.jdaoyun.a_empcsApi.service.TCarInfoService;
import com.jdaoyun.a_empcsApi.service.TDriverInfoService;
import com.jdaoyun.a_empcsApi.service.TMedicalStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 *每一季度最后一个自然日全量上传一次
 */
@Component
public class SpringTaskPush {

    @Autowired
    private PushCode pushCode;//推送代码

    @Autowired
    private Search search;//搜索存表

    @Autowired
    private TCarInfoService carInfoService;

    @Autowired
    private TDriverInfoService driverInfoService;

    @Autowired
    private TMedicalStaffService medicalStaffService;


    //每季度最后一个自然日全量上传一次（机构，车辆，司机，医护）
    @Scheduled(cron = "0 0 0 L 3,6,9,12 ? ")
    public void push() {
        if (ObjectUtil.isNotEmpty(carInfoService.list())) {//不是空的才执行
            carInfoService.remove(null);
        }
        search.carInfo();
        if (ObjectUtil.isNotEmpty(driverInfoService.list())) {//不是空的才执行
            driverInfoService.remove(null);
        }
        if (ObjectUtil.isNotEmpty(medicalStaffService.list())) {//不是空的才执行
            medicalStaffService.remove(null);
        }
        search.driver_Doctor_Nurse();
    }

}
